﻿using System.Reflection;
using System.Reflection.Emit;

namespace Yappi.ILGen
{
    public class DefaultPropertyImplementer:IPropertyImplementer
    {
        #region Implementation of IPropertyGetterImplementer

        public void ImplementGetter(MethodBuilder methodBuilder, PropertyInfo property)
        {
            var il = methodBuilder.GetILGenerator();
            var local = il.DeclareLocal(property.PropertyType);
            il.Emit(OpCodes.Ldloc,local);
            il.Emit(OpCodes.Ret);

        }

        #endregion

        #region Implementation of IPropertySetterImplementer

        public void ImplementSetter(MethodBuilder methodBuilder, PropertyInfo property)
        {
            var il = methodBuilder.GetILGenerator();
            il.Emit(OpCodes.Ret);
        }

        #endregion

        #region Implementation of IPropertyImplementer

        public void BeginEmit(TypeBuilder builder)
        {
            
        }

        public void EndEmit()
        {
            
        }

        #endregion

    }
}
